add argument type and flags to argument specifications as an aid to potential GUIs
authorparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 25 Jul 2003 16:09:43 +0000 (16:09 +0000)
committerparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 25 Jul 2003 16:09:43 +0000 (16:09 +0000)
18 files changed:
gpsbabel/arcdist.c
gpsbabel/cetus.c
gpsbabel/defs.h
gpsbabel/duplicate.c
gpsbabel/easygps.c
gpsbabel/filter_vecs.c
gpsbabel/gpilots.c
gpsbabel/gpspilot.c
gpsbabel/gpx.c
gpsbabel/magproto.c
gpsbabel/mapsource.c
gpsbabel/pcx.c
gpsbabel/polygon.c
gpsbabel/position.c
gpsbabel/quovadis.c
gpsbabel/tiger.c
gpsbabel/vecs.c
gpsbabel/xcsv.c

index bd0c7dd6cd87ff1ef1ef444a05c9581c679b1457..6bf7694470275253727b2c61aee47b9b822f7acc 100644 (file)
@@ -41,10 +41,12 @@ typedef struct {
 
 static
 arglist_t arcdist_args[] = {
-       {"file", &arcfileopt,  "File containing vertices of arc"},
-       {"distance", &distopt, "Maximum distance from arc"},
-       {"exclude", &exclopt, "Exclude points close to the arc"},
-       {0, 0, 0}
+       {"file", &arcfileopt,  "File containing vertices of arc", 
+               ARGTYPE_FILE | ARGTYPE_REQUIRED},
+       {"distance", &distopt, "Maximum distance from arc", 
+               ARGTYPE_FLOAT | ARGTYPE_REQUIRED},
+       {"exclude", &exclopt, "Exclude points close to the arc", ARGTYPE_BOOL},
+       {0, 0, 0, 0}
 };
 
 static double gcdist( double lat1, double lon1, double lat2, double lon2 ) {
index 713307e6334b76bf5eb2df5e3d805658e1f59447..bceb5099ea03e916e726342e104110eff12fb91b 100644 (file)
@@ -82,8 +82,8 @@ static char *dbname = NULL;
 
 static
 arglist_t cetus_args[] = {
-       {"dbname", &dbname, "Database name"},
-       {0, 0, 0}
+       {"dbname", &dbname, "Database name", ARGTYPE_STRING },
+       {0, 0, 0, 0 }
 };
 
 static void
index 22c9552efab3c00dd7b77d64eb566c098bda7777..273183b3f45e0c720be742f038e2b9f8f982736d 100644 (file)
@@ -235,10 +235,23 @@ void setshort_mustupper(void *, int n);
 void setshort_mustuniq(void *, int n);
 void setshort_whitespace_ok(void *, int n);
 
+#define ARGTYPE_UNKNOWN  0
+#define ARGTYPE_INT      0x00000001
+#define ARGTYPE_FLOAT    0x00000002
+#define ARGTYPE_STRING   0x00000003
+#define ARGTYPE_BOOL     0x00000004
+#define ARGTYPE_FILE     0x00000005
+#define ARGTYPE_OUTFILE  0x00000006
+#define ARGTYPE_REQUIRED 0x40000000
+
+#define ARGTYPE_TYPEMASK 0x00000fff
+#define ARGTYPE_FLAGMASK 0xfffff000
+
 typedef struct arglist {
        char *argstring;
        char **argval;
        char *helpstring;
+       long argtype;
 } arglist_t;
 
 typedef struct ff_vecs {
index cd5cc5dd3058be09028bff2a68122af7e8e0e1e0..570cf370157182fa43fe9f68f04724a97548071d 100644 (file)
@@ -28,9 +28,11 @@ static char *lcopt = NULL;
 
 static
 arglist_t dup_args[] = {
-       {"shortname", &snopt, "Suppress duplicate waypoints based on name"},
-       {"location", &lcopt, "Suppress duplicate waypoint based on coords"},
-       {0, 0, 0}
+       {"shortname", &snopt, "Suppress duplicate waypoints based on name",
+               ARGTYPE_BOOL},
+       {"location", &lcopt, "Suppress duplicate waypoint based on coords",
+               ARGTYPE_BOOL},
+       {0, 0, 0, 0}
 };
 
 
index efc67172ed278f264bae8fb740a04adfff6c663f..7ec472e4fbae41a32c06f2511b9f68e31b4f5c38 100644 (file)
@@ -31,8 +31,8 @@ static char *deficon = "Waypoint";
 
 static
 arglist_t easygps_args[] = {
-/*     {"deficon", &deficon, "Default icon name"}, */
-       {0, 0, 0}
+/*     {"deficon", &deficon, "Default icon name", ARGTYPE_STRING}, */
+       {0, 0, 0, 0 }
 };
 
 static void
index 791a77cf30536470b0cc970bb0d6c0899dc0859f..c8b84afd3b7400254eab8c474c78757e72ae0f33 100644 (file)
@@ -127,8 +127,9 @@ disp_filter_vecs(void)
                printf("        %-20.20s  %-50.50s\n",
                        vec->name, vec->desc);
                for (ap = vec->vec->args; ap && ap->argstring; ap++) {
-                       printf("          %-18.18s    %-.50s\n",
-                               ap->argstring, ap->helpstring);
+                       printf("          %-18.18s    %-.50s %s\n",
+                               ap->argstring, ap->helpstring,
+                               (ap->argtype&ARGTYPE_REQUIRED)?"(required)":"");
                }
        }
 }
index 2bda982daf39e88cc450b0dae254cc14007cd981..9759ecf9cc27374ba7b74af7375e14356394968f 100644 (file)
@@ -117,8 +117,8 @@ static char *dbname = NULL;
 
 static
 arglist_t my_args[] = {
-       {"dbname", &dbname, "Database name"},
-       {0, 0, 0}
+       {"dbname", &dbname, "Database name", ARGTYPE_STRING},
+       {0, 0, 0, 0}
 };
 
 static void
index 267fea2b6d91ea930dbd3ebe25ab6412716292b4..61362df275563f9daeafc9f3bb639dc1d7fc52e7 100644 (file)
@@ -54,8 +54,8 @@ static char *dbname = NULL;
 
 static
 arglist_t gpspilot_args[] = {
-        {"dbname", &dbname, "Database name"},
-        {0, 0, 0}
+        {"dbname", &dbname, "Database name", ARGTYPE_STRING},
+        {0, 0, 0, 0}
 };
 
 static void
index be421e9940ee881a424b081cb2e54c55ce0cb2ec..9de09829b18d0bcb1144e2d2bd046e310979b475 100644 (file)
@@ -63,6 +63,9 @@ static FILE *fd;
 static FILE *ofd;
 static void *mkshort_handle;
 
+static const char *input_string = NULL;
+static int input_string_len = 0;
+
 static time_t file_time;
 
 static char *gsshortnames = NULL;
@@ -733,9 +736,16 @@ gpx_cdata(void *dta, const XML_Char *s, int len)
 void
 gpx_rd_init(const char *fname, const char *args)
 {
-       fd = fopen(fname, "r");
-       if (fd == NULL) {
-               fatal(MYNAME ": Cannot open %s for reading\n", fname );
+       if ( fname[0] ) {
+               fd = fopen(fname, "r");
+               if (fd == NULL) {
+                       fatal(MYNAME ": Cannot open %s for reading\n", fname );
+               }
+       }
+       else {
+               fd = NULL;
+               input_string = fname+1;
+               input_string_len = strlen(input_string);
        }
 
         if (get_option(args, "logpoint") != NULL)
@@ -758,7 +768,9 @@ gpx_rd_deinit(void)
        if ( cdatastr ) {
                xfree(cdatastr);
        }
-       fclose(fd);
+       if (fd) {
+               fclose(fd);
+       }
 }
 
 void
@@ -786,11 +798,25 @@ gpx_read(void)
        int len;
        int done = 0;
        char buf[MY_CBUF];
+       int result = 0;
 
        while (!done) {
-               len = fread(buf, 1, sizeof(buf), fd);
-               done = feof(fd) || !len; 
-               if (!XML_Parse(psr, buf, len, done)) {
+               if ( fd ) {
+                       len = fread(buf, 1, sizeof(buf), fd);
+                       done = feof(fd) || !len;
+                       result = XML_Parse(psr, buf, len, done);
+               }
+               else if (input_string) {
+                       done = 0;
+                       result = XML_Parse(psr, input_string, 
+                                       input_string_len, done );
+                       done = 1;
+               }
+               else {
+                       done = 1;
+                       result = -1;
+               }
+               if (!result) {
                        fatal(MYNAME ": XML parse error at %d: %s\n", 
                                XML_GetCurrentLineNumber(psr),
                                XML_ErrorString(XML_GetErrorCode(psr)));
@@ -1131,10 +1157,13 @@ gpx_write(void)
 
 static
 arglist_t gpx_args[] = {
-       { "gsshortnames", &gsshortnames, "Prefer shorter descriptions from Groundspeak files"},
-       { "snlen", &snlen, "Length of generated shortnames" },
-       { "suppresswhite", &suppresswhite, "Suppress whitspace in generated shortnames" },
-       { 0, 0, 0}
+       { "gsshortnames", &gsshortnames, 
+               "Prefer shorter descriptions from Groundspeak files",
+               ARGTYPE_BOOL },
+       { "snlen", &snlen, "Length of generated shortnames", ARGTYPE_INT },
+       { "suppresswhite", &suppresswhite, 
+               "Suppress whitespace in generated shortnames", ARGTYPE_BOOL },
+       { 0, 0, 0, 0 }
 };
 
 ff_vecs_t gpx_vecs = {
index c23ea016771909c422ea5c7b34d80a4fadad429e..90d66e07d974afdc063d72a97f88104a65694b6d 100644 (file)
@@ -689,10 +689,11 @@ termwrite(char *obuf, int size)
 
 static
 arglist_t mag_args[] = {
-       {"baud", &bs, "Numeric value of bitrate (baud=4800)"},
-       {"noack", &noack, "Suppress use of handshaking in name of speed"},
-       {"deficon", &deficon, "Default icon name"},
-       {0, 0, 0}
+       {"baud", &bs, "Numeric value of bitrate (baud=4800)", ARGTYPE_INT },
+       {"noack", &noack, "Suppress use of handshaking in name of speed",
+               ARGTYPE_BOOL},
+       {"deficon", &deficon, "Default icon name", ARGTYPE_STRING },
+       {0, 0, 0, 0}
 };
 
 static void
index 553a86f97f18fa328a94505ab5d7e13a06b43c60..26f2f1b7b3b7bf3f7c163ed5103ec7e66888a2b8 100644 (file)
@@ -52,8 +52,8 @@ char *snlen;
 
 static
 arglist_t mps_args[] = {
-       {"snlen", &snlen, "Length of generated shortnames" },
-       {0, 0, 0}
+       {"snlen", &snlen, "Length of generated shortnames", ARGTYPE_INT },
+       {0, 0, 0, 0}
 };
 
 const char *
index 7faa6888ccd5914e89855950eea3fa05f5162a0d..5ba54d38fe517fcb744fd31d4fe4361fe8efaa08 100644 (file)
@@ -32,8 +32,8 @@ static char *deficon = "Waypoint";
 
 static
 arglist_t pcx_args[] = {
-       {"deficon", &deficon, "Default icon name"},
-       {0, 0, 0}
+       {"deficon", &deficon, "Default icon name", ARGTYPE_STRING },
+       {0, 0, 0, 0}
 };
 
 static void
index fbc7ae56c4b0f21a2deeddcabf07cb2bd481735d..4386cad18d33692a87c97483142ae5e313d848df 100644 (file)
@@ -49,9 +49,11 @@ typedef struct {
 
 static
 arglist_t polygon_args[] = {
-       {"file", &polyfileopt,  "File containing vertices of polygon"},
-       {"exclude", &exclopt, "Exclude points inside the polygon"},
-       {0, 0, 0}
+       {"file", &polyfileopt,  "File containing vertices of polygon",
+               ARGTYPE_FILE | ARGTYPE_REQUIRED },
+       {"exclude", &exclopt, "Exclude points inside the polygon",
+               ARGTYPE_BOOL },
+       {0, 0, 0, 0}
 };
 
 static void polytest ( double lat1, double lon1,
index 3b49670995c4a7696a804bfd8479861af31c57c3..82a2d12889e9fa4571052f7498a7405f39569b00 100644 (file)
@@ -42,17 +42,22 @@ typedef struct {
 
 static
 arglist_t position_args[] = {
-       {"distance", &distopt, "Maximum positional distance (required)"},
-       {0, 0, 0}
+       {"distance", &distopt, "Maximum positional distance",
+               ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+       {0, 0, 0, 0}
 };
 
 static
 arglist_t radius_args[] = {
-       {"lat", &latopt,       "Latitude for center point (D.DDDDD)"},
-       {"lon", &lonopt,       "Longitude for center point (D.DDDDD)"},
-       {"distance", &distopt, "Maximum distance from center"},
-       {"exclude", &exclopt,  "Exclude points close to center"},
-       {0, 0, 0}
+       {"lat", &latopt,       "Latitude for center point (D.DDDDD)",
+               ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+       {"lon", &lonopt,       "Longitude for center point (D.DDDDD)",
+               ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+       {"distance", &distopt, "Maximum distance from center",
+               ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+       {"exclude", &exclopt,  "Exclude points close to center",
+               ARGTYPE_BOOL },
+       {0, 0, 0, 0}
 };
 
 static double
index ef2631b871f35f61286f3588456dc1f1c4fc90b4..bcc226ae46c1cddc0128f96a9b79660e4e4448b8 100644 (file)
@@ -35,8 +35,8 @@ static char *dbname = NULL;
 
 static
 arglist_t quovadis_args[] = {
-       {"dbname", &dbname, "Database name"},
-       {0, 0, 0}
+       {"dbname", &dbname, "Database name", ARGTYPE_STRING},
+       {0, 0, 0, 0}
 };
 
 static struct qv_icon_mapping mapping[] = {
index bafedc465f23da284d77963df90fa39f9be9471d..4a97d4c085f08e19165472614dc46ed0f3e96dba 100644 (file)
@@ -48,13 +48,17 @@ static char *clickmap = NULL;
 
 static
 arglist_t tiger_args[] = {
-       {"nolabels", &nolabels, "Suppress labels on generated pins."},
-       {"genurl", &genurl, "Generate file with lat/lon for centering map."},
-       {"scale", &scale, "Dimension in pixels of map."},
+       {"nolabels", &nolabels, "Suppress labels on generated pins.",
+               ARGTYPE_BOOL },
+       {"genurl", &genurl, "Generate file with lat/lon for centering map.",
+               ARGTYPE_OUTFILE },
+       {"scale", &scale, "Dimension in pixels of map.",
+               ARGTYPE_INT},
 #if CLICKMAP
-       {"clickmap", &clickmap, "Generate Clickable map web page."},
+       {"clickmap", &clickmap, "Generate Clickable map web page.",
+               ARGTYPE_BOOL},
 #endif
-       {0, 0, 0}
+       {0, 0, 0, 0}
 };
 
 
index 2f2833901b476aa2b3d559da47e6b24843c8fea7..3d7cd943b70ff2ef31243d193ad40fa6a16ef71c 100644 (file)
@@ -339,8 +339,9 @@ disp_vecs(void)
        for (vec = vec_list; vec->vec; vec++) {
                printf(VEC_FMT, vec->name, vec->desc);
                for (ap = vec->vec->args; ap && ap->argstring; ap++) {
-               printf("          %-18.18s    %-.50s\n",
-                       ap->argstring, ap->helpstring);
+               printf("          %-18.18s    %-.50s %s\n",
+                       ap->argstring, ap->helpstring,
+                       (ap->argtype & ARGTYPE_REQUIRED)?"(required)":"");
                }
        }
 
index e3edbecc864f8b46affd06422a8a1d132d5c5ff8..248ef58d83084ed0075ab3b3e8c4fd365f6371c4 100644 (file)
@@ -40,14 +40,21 @@ char *xcsv_urlbase;
 
 static
 arglist_t xcsv_args[] = {
-       {"style", &styleopt, "Full path to XCSV style file (required)"},
-       {"snlen", &snlenopt, "Max synthesized shortname length"},
-       {"snwhite", &snwhiteopt, "(0/1) Allow whitespace synth. shortnames"},
-       {"snupper", &snupperopt, "(0/1) UPPERCASE synth. shortnames"},
-       {"snunique", &snuniqueopt, "(0/1) Make synth. shortnames unique"},
-       {"urlbase", &xcsv_urlbase, "Basename prepended to URL on output"},
-       {"prefer_shortnames", &prefer_shortnames, "Use shortname instead of description"},
-       {0, 0, 0}
+       {"style", &styleopt, "Full path to XCSV style file",
+               ARGTYPE_FILE | ARGTYPE_REQUIRED },
+       {"snlen", &snlenopt, "Max synthesized shortname length",
+               ARGTYPE_INT},
+       {"snwhite", &snwhiteopt, "(0/1) Allow whitespace synth. shortnames",
+               ARGTYPE_BOOL},
+       {"snupper", &snupperopt, "(0/1) UPPERCASE synth. shortnames",
+               ARGTYPE_BOOL},
+       {"snunique", &snuniqueopt, "(0/1) Make synth. shortnames unique",
+               ARGTYPE_BOOL},
+       {"urlbase", &xcsv_urlbase, "Basename prepended to URL on output",
+               ARGTYPE_STRING},
+       {"prefer_shortnames", &prefer_shortnames, 
+               "Use shortname instead of description", ARGTYPE_BOOL },
+       {0, 0, 0, 0}
 };
 
 /* a table of config file constants mapped to chars */